import { createRouter, createWebHistory } from 'vue-router'
import Layout from '@/layout/index.vue'
import Login from '@/views/login/indexPage.vue'

const routes = [
  {
    path: '/',
    redirect: '/login',
  },
  {
    path: '/login',
    component: Login,
    name: 'login',
    meta: { title: '登录' }
  },
  {
    path: '/home',
    component: Layout,
    children: [
      {
        path: 'category',
        component: () => import('@/views/category/index.vue'),
        name: 'classify',
        meta: { title: '分类管理', icon: 'user' }
      },
      {
        path: 'product',
        component: () => import('@/views/product/index.vue'),
        name: 'product',
        meta: { title: '商品管理', icon: 'user' }
      },
      {
        path: 'order',
        component: () => import('@/views/order/index.vue'),
        name: 'order',
        meta: { title: '订单管理', icon: 'user' }
      },
      {
        path: 'user',
        component: () => import('@/views/user/index.vue'),
        name: 'user',
        meta: { title: '用户管理', icon: 'user' }
      },
      {
        path: 'customer',
        component: () => import('@/views/customer/index.vue'),
        name: 'customer',
        meta: { title: '客户管理', icon: 'user' }
      },
      {
        path: 'brand',
        component: () => import('@/views/brand/index.vue'),
        name: 'brand',
        meta: { title: '品牌管理', icon: 'user' }
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes: routes
})

export default router
